import { fileURLToPath, URL } from 'node:url';

import { PrimeVueResolver } from '@primevue/auto-import-resolver';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
// 1、导入inject插件
import inject from '@rollup/plugin-inject'





export default defineConfig({
    plugins: [
        vue(),
        //2、 在plugins属性下加入以下配置，它可以在全局注入quill
        inject({
            'window.Quill': ['@vueup/vue-quill', 'Quill'],
            Quill: ['@vueup/vue-quill', 'Quill']
        }),
        Components({
            resolvers: [PrimeVueResolver()]
        })
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    base: '/questionBankManage/',
    server:
        process.env.NODE_ENV === 'development'
            ? {
                  proxy: {
                      // 将所有 /api 开头的请求代理到目标服务器
                      '/api': {
                          target: 'http://127.0.0.1:8087',
                          changeOrigin: true,
                          rewrite: (path) => path.replace(/^\/api/, '')
                      }
                  }
              }
            : {}
});
